package com.ican.dao.product;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.ican.common.hibernate.HibernateDao;
import com.ican.domain.product.ProductImage;

@Repository("productImageDao")
public class ProductImageDao extends HibernateDao<ProductImage, Integer> {

    public void deleteProductImageByProductId(Integer productId){
        String hql = "delete from ProductImage where productId = ?";
        this.batchExecute(hql, productId);
    }
    
    public List<ProductImage> findProductImageByProductIdAndCode(Integer productId, String code){
        String hql = "from ProductImage where productId = ? and code = ?";
        return this.find(hql, new Object[]{productId, code});
    }
    
    public List<ProductImage> findProductImageByProductId(Integer productId){
        String hql = "from ProductImage where productId = " + productId;
        return this.find(hql);
    }
}
